package com.brainshare.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 二级红包类型枚举
 * @author wll
 */
public enum RedPacketType2Enum {
    ANALYSE(0, 290, "筛查红包"),
    COMPLETED_INFO_FILL(1, 360, "完成信息填写红包"),
    COMPLETED_PHYSICAL_EXAMINATION(2, 170, "完成体检红包"),
    SHARE(3, 0, "分享好友");

    //编码
    private final Integer code;
    //金额
    private final Integer amount;
    //描述
    private final String info;

    RedPacketType2Enum(Integer code, Integer amount, String info) {
        this.code = code;
        this.amount = amount;
        this.info = info;
    }

    public static Map<Integer, Integer> getShareAmountMap() {
        Map<Integer, Integer> map = new HashMap<>();
        map.put(1, 27);
        map.put(2, 13);
        map.put(3, 115);
        map.put(4, 2);
        map.put(5, 10);
        return map;
    }


    public static Integer getAmountByCode(Integer code,Integer shareTime)
    {
        if (null==code){
            return null;
        }

        if (SHARE.code.equals(code)){
            Map<Integer, Integer> shareAmountMap = getShareAmountMap();
            Integer amount = shareAmountMap.get(shareTime);
            return amount;
        }

        for (RedPacketType2Enum redPacketType2Enum : RedPacketType2Enum.values()) {
            if (code==redPacketType2Enum.getCode()){
                return redPacketType2Enum.getAmount();
            }
        }
        return null;
    }


    public static boolean checkRedPacketType(int redPacketType)
    {
        List<Integer> redPacketCodeList = getRedPacketCodeList();
        return redPacketCodeList.contains(redPacketType);
    }

    public static List<Integer> getRedPacketCodeList(){
        List<Integer> redPacketCodeList = new ArrayList<>();
        for (RedPacketType2Enum redPacketType2Enum : RedPacketType2Enum.values()) {
            redPacketCodeList.add(redPacketType2Enum.getCode());
        }
        return redPacketCodeList;
    }

    public Integer getCode() {
        return code;
    }

    public Integer getAmount() {
        return amount;
    }

    public String getInfo() {
        return info;
    }
}
